package soft.edu.service.Impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import soft.edu.common.ServerResponse;
import soft.edu.dao.SchMajorCatalogMapper;
import soft.edu.pojo.SchMajorCatalog;
import soft.edu.service.SchMajorCatalogService;

import java.util.List;

@Controller("schMajorCatalogService")
public class SchMajorCatalogServiceImpl implements SchMajorCatalogService {

    @Autowired
    private SchMajorCatalogMapper schMajorCatalogMapper;

//    根据院校名称获取所有专业信息
    @Override
    public ServerResponse<List<SchMajorCatalog>> getInfo(String year,String maj_uni_name,
                                                        String maj_college_name, String maj_name) {
        List<SchMajorCatalog> listSchMajorCatalog =schMajorCatalogMapper.getInfo(year,maj_uni_name, maj_college_name, maj_name);
        if(listSchMajorCatalog.isEmpty()){
            return ServerResponse.createByErrorMessage("专业信息查询不到");
        }else {
            return ServerResponse.createBySuccess("专业信息查询成功",listSchMajorCatalog);
        }
    }

    //返回院系列表
    @Override
    public ServerResponse<List<String>> getCollege(String maj_uni_name) {
        List<String> listCollegeByUni = schMajorCatalogMapper.getCollege(maj_uni_name);
        if(listCollegeByUni.isEmpty()){
            return ServerResponse.createByErrorMessage("院系列表查询不到");
        }else {
            return ServerResponse.createBySuccess("院系列表查询成功",listCollegeByUni);
        }
    }

//    返回专业列表
    @Override
    public ServerResponse<List<String>> getMajor(String maj_uni_name) {
        List<String> listMajorByUni = schMajorCatalogMapper.getMajor(maj_uni_name);
        if(listMajorByUni.isEmpty()){
            return ServerResponse.createByErrorMessage("专业列表查询不到");
        }else {
            return ServerResponse.createBySuccess("专业列表查询成功",listMajorByUni);
        }
    }

//    根据学科类型返回对应的专业目录(有学科评估等级)
    @Override
    public ServerResponse<List<String>> getMajorwithSubject(String maj_subject) {
        List<String> listMajorwithLevel = schMajorCatalogMapper.getMajorwithSubject(maj_subject);
        if(listMajorwithLevel.isEmpty()){
            return ServerResponse.createByErrorMessage("学科类型对应的专业目录查询不到");
        }else {
            return ServerResponse.createBySuccess("学科类型对应的专业目录查询成功",listMajorwithLevel);
        }
    }
}
